﻿using ActivitiesPlan.dao;
using ActivitiesPlan.domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ActivitiesPlan {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();

            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            this.WindowState = WindowState.Maximized;

            setupActivityCombos();

        }

        // ----------------------------------------------------------------------------------------

        private void DataGrid_Loaded(object sender, RoutedEventArgs e) {
            String s = "17:00-18:00";
            //this.dataGrid.Items.Add(s);
            //this.dataGrid.Items.Add(s);
        }

        // ----------------------------------------------------------------------------------------

        private void Button_Click(object sender, RoutedEventArgs e) {
            calculatePlan();
        }

        // ----------------------------------------------------------------------------------------

        private void calculatePlan() {
            
            Console.WriteLine("Calculate Plan");

            ComboBox comboBox = getComboboxFromGrid(1, 1);
            Console.WriteLine(comboBox.SelectedValue);
        }

        // ----------------------------------------------------------------------------------------

        private void setupActivityCombos() {
            ActivityDao activityDao = new ActivityDao();
            List<Activity> activities = activityDao.getAllActivities();

            ComboBox c = getComboboxFromGrid(1, 1);
            ComboBoxItem item = new ComboBoxItem();

            c.Items.Add(activities[0].Description);
        }

        // ----------------------------------------------------------------------------------------

        private ComboBox getComboboxFromGrid(int row, int column) {
            return (ComboBox)this.mainGrid.Children.Cast<UIElement>().First(e => Grid.GetRow(e) == row && Grid.GetColumn(e) == column);
        }
    }
}
